package com.yunxi.controller.order;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.order.pojo.*;
import com.yunxi.order.service.RetailMonthlyPlanDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/retailMonthlyPlan")
@Api(tags = "pms:retailMonthlyPlan", description = "分销月计划接口")
public class RetailMonthlyPlanController {
    @Autowired
    private RetailMonthlyPlanDubboService retailMonthlyPlanDubboService;

    @ApiOperation(value = "保存渠道商目标计划")
    @PostMapping(value = "/save")
    public ApiResult<Boolean> save(@CurrentUser LoginInfo user, @RequestBody RetailMonthlyPlanSaveReqVO vo){
        boolean isSuccess =retailMonthlyPlanDubboService.save(vo);
        return ResponseUtil.ok(isSuccess);
    }

    @ApiOperation(value = "提交渠道商目标计划")
    @PostMapping(value = "/submit")
    public ApiResult<Boolean> submit(@CurrentUser LoginInfo user,@RequestBody RetailMonthlyPlanSubmitReqVO vo){
        boolean isSuccess =retailMonthlyPlanDubboService.submit(vo);
        return ResponseUtil.ok(isSuccess);
    }

    @ApiOperation(value = "查询渠道商目标计划")
    @GetMapping(value = "/queryRetailMonthlyPlan")
    public ApiResult<RetailMonthlyPlanQueryRespVO> queryRetailMonthlyPlan(@CurrentUser LoginInfo user, RetailMonthlyPlanQueryReqVO vo,int pageNum,int pageSize){
        List<RetailMonthlyPlanQueryRespVO> list = retailMonthlyPlanDubboService.queryRetailMonthlyPlan(vo,pageNum,pageSize);
        return ResponseUtil.ok(list);
    }

    @ApiOperation(value = "修改渠道商目标计划")
    @PostMapping(value = "/modifyRetailMonthlyPlan")
    public ApiResult<Boolean> modifyRetailMonthlyPlan(@CurrentUser LoginInfo user,@RequestBody RetailMonthlyPlanModifyReqVO vo){
        boolean isSuccess = retailMonthlyPlanDubboService.modifyRetailMonthlyPlan(vo);
        return ResponseUtil.ok(isSuccess);
    }

}
